<form method="POST" action="index.php?ctl=plugins/logistic&act=save" class="tableform" id="logistic_form" extra="subLogistic">
    <div id="logistic_check">
        <h4>收货人信息</h4>
        <div class="division">
            <table width="100%" border="0" cellpadding="0" cellspacing="0">
                <tr>
                  <th><{t}>收货人姓名：<{/t}></th>
                  <td><{input type="text" name="ship_name" size="20" required="true"}></td>
                </tr>
                <tr>
                  <th><{t}>收货人地区：<{/t}></th>
                  <td>
                    <{input type="region" required="true" name="ship_area" id="ship_area" vtype="area"}>
                  </td>
                </tr>
                <tr>
                  <th><{t}>配送方式：<{/t}></th>
                  <td><{input type="text" name="delivery" required="true"}></td>
                </tr>
                <tr>
                  <th><{t}>收货人手机：<{/t}></th>
                  <td>
                    <{input type="text" name="ship_mobile"}>
                    <span>请填写 电话 或 手机 其中至少一种联系方式！</span>
                  </td>
                </tr>
                <tr>
                  <th><{t}>收货人电话：<{/t}></th>
                  <td><{input type="text" name="ship_tel"}></td>
                </tr>
                <tr>
                  <th><{t}>收货人地址：<{/t}></th>
                  <td><{input type="text" name="ship_addr" required="true"}></td>
                </tr>
                <tr>
                  <th><{t}>收货人Email：<{/t}></th>
                  <td><{input type="text" name="ship_email"}></td>
                </tr>
                <tr>
                  <th><{t}>收货人邮编：<{/t}></th>
                  <td><{input type="text" name="ship_zip"}></td>
                </tr>
                <tr>
                  <th><{t}>备注：<{/t}></th>
                  <td><{input type="text" name="memo"}></td>
                </tr>
                <tr>
                  <th><{t}>状态：<{/t}></th>
                  <td>
                    <{input type="select" options=$status value="process"}>
                  </td>
                </tr>
            </table>
        </div>

        <h4>物品信息</h4>
        <div class="tableform">
            <{button label="添加物品信息" type="button" id="add_goods_info" icon="btn_add.gif"}>
        </div>
    </div>

    <div class="table-action">
        <{button type="submit" label="保存"}>
    </div>
</form>

<div id="hidden_info" style="display:none;">
    <div class="division">
        <span class="sysiconBtn delete" onclick="delRow(this)"><{t}>删除此组物品<{/t}></span>
        <table width="100%" border="0" cellpadding="0" cellspacing="0">
            <tr>
              <th><{t}>物品名称：<{/t}></th>
              <td>
                <{input type="text" name="goods_name" required="true"}>
              </td>
              <th><{t}>物品数量：<{/t}></th>
              <td><{input type="text" name="goods_num" required="true" vtype="unsignedint"}></td>
            </tr>
            <tr>
              <th><{t}>物品重量：<{/t}></th>
              <td><{input type="text" name="goods_weight" vtype="signed"}></td>
              <th><{t}>物品体积：<{/t}></th>
              <td><{input type="text" name="goods_volume" vtype="signed"}></td>
            </tr>
        </table>
    </div>
</div>
<div id="hidden_info_orig" style="display:none;">
    <div class="division">
        <table width="100%" border="0" cellpadding="0" cellspacing="0">
            <tr>
              <th><{t}>物品名称：<{/t}></th>
              <td>
                <{input type="text" name="goods_name" required="true"}>
                <span class="sysiconBtn delete" onclick=""><{t}>删除此组物品<{/t}></span>
              </td>
            </tr>
            <tr>
              <th><{t}>物品数量：<{/t}></th>
              <td><{input type="text" name="goods_num" required="true"}></td>
            </tr>
            <tr>
              <th><{t}>物品重量：<{/t}></th>
              <td><{input type="text" name="goods_weight" required="true"}></td>
            </tr>
            <tr>
              <th><{t}>物品体积：<{/t}></th>
              <td><{input type="text" name="goods_volume" required="true"}></td>
            </tr>
        </table>
    </div>
</div>

<script>
    window.addEvent('domready',function(){
        $('add_goods_info').addEvent('click',function(){
            var time = $time();
            var btnDiv = $E('#hidden_info div').clone();
            $(btnDiv).getElements('input').each(function(v,k){
                var name = v.get('name');
                v.set('name','goods['+time+']['+name+']');
            });
            btnDiv.inject(this.getParent('div'));
        });
        $('add_goods_info').fireEvent('click');
    });

    function delRow(el)
    {
        $(el).getParent('div').destroy();
    }

void function(){

var _warning=function(msg,go){
    alert(msg);
    go.show();
     window.scrollTo(0,(go||$('logistic_form')).getPosition().y-50);
};

if(!extra_validator['subLogistic']){
  extra_validator['subLogistic'] = {
    'logistic_form':['',function(f,i){
        if($('logistic_check').getElement('input[name=ship_tel').getProperty('value').trim() == '' && $('logistic_check').getElement('input[name=ship_mobile').getProperty('value').trim() == ''){
          _warning('请填写 电话 或 手机 其中至少一种联系方式！',$('logistic_check'));
          return false;
        }
        return true;
      }]
  };
}
}();
</script>
